<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no"/>
	<title>正在处理</title>
	<style>
	.loading {
		width: 130px;
		padding-top: 10px;
		padding: 10px;
		background: rgba(0,0,0,0.6);
		border-radius: 3px;
		margin: 250px auto;
		color: #fff;
		font-size: 12px;
		line-height: 14px;
		text-align: center;
	}
	.loading i {
			margin: 0 auto;
			display: block;
			width:33px;
			height: 33px;
			background: url(img/load.png) center no-repeat;
			background-size: 33px 33px; 
			margin-bottom: 10px;
			-webkit-animation-name: loading;
			-webkit-animation-duration: 1.4s;
			-webkit-animation-iteration-count: infinite;
			-webkit-animation-timing-function: linear;
		}

		@-webkit-keyframes loading {
			from { -webkit-transform: rotate(0deg) translateZ(0); }
			to { -webkit-transform: rotate(360deg) translateZ(0); }
		}
	</style>
</head>
<body>
	<div class="loading">
		<i></i>
		正在处理，请稍后...
	</div>
</body>
<script src="js/common.js"></script>
<script src="js/jquery.js"></script>
	<script>
		var code = getQueryString('code');

		//认证
		function getInfo(){
			$.ajax({
		        cache: false,
		        type: "GET",
				dataType: "JSON",
		        url:API_URL+"agent/getuser?code="+code,  //此处需要将API_URL写全局
		        async: false,
		        success: function(jsonobj) {
					
					if(jsonobj.status.code == 2){
						//代理人
						var myData = jsonobj.basedata;
						var openid = myData.openid;
						window.location = 'main_card.html?origopenid='+openid+'&agent_status=1';
					}else if(jsonobj.status.code == 0){
						//未认证
						var myData = jsonobj.basedata;
						var openid = myData.openid;
						window.location = 'validate.html?openid='+openid;
					}else{
						window.location = 'error.html';
					}

					/*
		        	if(jsonobj.status.code == 0){
						//未绑定代理人的客户
						var myData = jsonobj.basedata;
						var openid = myData.openid;
						window.location = 'search_card.html?openid='+openid;
					}

					if(jsonobj.status.code == 1){
						//已绑定代理人的客户
						var myData = jsonobj.basedata;
						var openid = myData.openid;
						window.location = 'main_card.html?openid='+openid+'&agent_status=0';
					}

					if(jsonobj.status.code == 2){
						//代理人
						var myData = jsonobj.basedata;
						var openid = myData.openid;
						window.location = 'main_card.html?openid='+openid+'&agent_status=1';
					}

					if(jsonobj.status.code == -1 || jsonobj.status.code == -2 ){
						//无效的code或无效的openid
						window.location = 'error.html';
					}
					*/
					
		        },
				error: function(request) {
		            //跳转错误页面
					window.location = 'error.html';
		        }
		    });
		}


		function showload(){
			
			if(code==''){
				alert('获取用户授权失败!');
				return;
			}

			
			getInfo();
		}

		showload();
	</script>
</html>